package main

//https://leetcode-cn.com/problems/optimal-division/
//保证结果最大，被除数固定，则除数最小
//a/(b/c/d/e/f) = a * c * d * e * f / b
import (
	"fmt"
	"strconv"
)

func optimalDivision(nums []int) string {
	l := len(nums)
	res := strconv.Itoa(nums[0])
	if l == 1 {
		return res
	} else if l == 2 {
		return res + "/" + strconv.Itoa(nums[1])
	} else {
		res += "/("
		for i := 1; i < l; i++ {
			res += strconv.Itoa(nums[i])
			if i != l-1 {
				res += "/"
			}
		}
		res += ")"
		return res
	}
}

func main() {
	fmt.Println(optimalDivision([]int{1000, 100, 10, 2}))
	fmt.Println(optimalDivision([]int{1000}))
	fmt.Println(optimalDivision([]int{1000, 2}))
}
